package com.zmj.sy.mom.srv.aps.controller;

import com.zmj.sy.mom.srv.aps.bean.vo.reportErp.*;
import com.zmj.sy.mom.srv.aps.bean.vo.base.Result;
import com.zmj.sy.mom.srv.aps.service.NoreportErpConfigService;
import io.swagger.annotations.Api;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;

/**
 * 工单不回传配置(NoreportErpConfig)表控制层
 *
 * @author hejiahui
 * @since 2025-07-31 11:45:15
 */
@Api(tags = "工单不回传配置")
@RestController
@RequestMapping("tbMesNoreportErpConfig")
public class NoreportErpConfigController {

    @Autowired
    private NoreportErpConfigService noreportErpConfigService;

    /**
     * 分页查询
     *
     * @param noreportErpConfigReqVo 筛选条件
     * @return 查询结果
     */
    @ApiOperation(value ="分页查询")
    @GetMapping("/queryPage")
    public Result<IPage<NoreportErpConfigResVo>> queryByPage(NoreportErpConfigReqVo noreportErpConfigReqVo) {
        return Result.success(this.noreportErpConfigService.queryByPage(noreportErpConfigReqVo));
    }

    /**
     * 新增数据
     *
     * @param tbMesNoreportErpConfigReqVo 实体
     * @return 新增结果
     */
    @ApiOperation(value ="新增数据")
    @PostMapping("/add")
    public Result add(@RequestBody NoreportErpConfigAddListVo tbMesNoreportErpConfigReqVo) {
        this.noreportErpConfigService.insert(tbMesNoreportErpConfigReqVo);
        return Result.success();
    }

    /**
     * 编辑数据
     *
     * @param tbMesNoreportErpConfigReqVo 实体
     * @return 编辑结果
     */
    @ApiOperation(value ="编辑数据")
    @PostMapping("/update")
    public Result update(@RequestBody NoreportErpConfigAddVo tbMesNoreportErpConfigReqVo) {
        this.noreportErpConfigService.update(tbMesNoreportErpConfigReqVo);
        return Result.success();
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @ApiOperation(value ="删除数据")
    @PostMapping("/deleteById")
    public Result deleteById(@RequestBody  List<Integer> ids) {
        for (Integer id : ids) {
            this.noreportErpConfigService.deleteById(id);
        }
        return Result.success();
    }
    /**
     * @Description: 根据施工号获取零件
     *
     * @author: hejiahui
     * @since: 2025/8/1 10:32
     */
    @ApiOperation(value ="根据施工号获取零件")
    @GetMapping("/getWorkOrderCodeByOrder")
    public Result<List<ReportErpPartInfoVo>> getWorkOrderCodeByOrder(
            @ApiParam(value = "施工号", required = true) @RequestParam(name = "orderCode") String orderCode,
            @ApiParam(value = "零件号") @RequestParam(name = "plmid",required = false) String plmid) {
        return Result.success(this.noreportErpConfigService.getWorkOrderCodeByOrder(orderCode,plmid));
    }
    /**
     * @Description: 获取工序
     *
     * @author: hejiahui
     * @since: 2025/8/1 10:32
     */
    @ApiOperation(value ="获取工序")
    @GetMapping("/getWorkPhase")
    public Result<List<String>> getWorkPhase(
            @ApiParam(value = "施工号", required = true) @RequestParam(name = "orderCode") String orderCode,
            @ApiParam(value = "零件号", required = true) @RequestParam(name = "plmid") String plmid,
            @ApiParam(value = "工序") @RequestParam(name = "phase",required = false) String phase) {
        return Result.success(this.noreportErpConfigService.getWorkPhase(orderCode,plmid,phase));
    }
    /**
     * 配置查询
     *
     * @param noreportErpConfigReqVo 筛选条件
     * @return 查询结果
     */
    @ApiOperation(value ="成品配置查询")
    @GetMapping("/queryList")
    public Result<List<NoreportErpConfigResVo>> queryList(FinishedConfigReqVo finishedConfigReqVo) {
        return Result.success(this.noreportErpConfigService.queryList(finishedConfigReqVo));
    }
}

